package Operation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:增加书籍
 * User: 86184
 * Date: 2023-02-18
 * Time: 15:17
 */
public class AddOperation implements IOperation {
    public void work(BookList bookList) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要新增的图书的书名");
        String name = scanner.nextLine();
        System.out.println("请输入你要新增的图书的作者");
        String author = scanner.nextLine();
        System.out.println("请输入你要新增的图书的价格");
        int price = scanner.nextInt();
        scanner.nextLine();
        System.out.println("请输入你要新增的图书的类型");
        String type = scanner.nextLine();

        int currentSize=bookList.getUseSize();
        Book book=new Book(name,author,price,type);

        bookList.setBooks(book,currentSize);

        bookList.setUseSize(currentSize+1);
        System.out.println("添加成功");
    }
}
